<!doctype html>
<html lang="zh-CN">
<head>
    <!-- 必须的 meta 标签 -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap 的 CSS 文件 -->
    <link rel="stylesheet" href="../../css/bootstrap.min.css" >
    <link rel = "stylesheet" href="../../css/font-awesome.min.css">
    <link rel="stylesheet" href="../control/assest/css/dashboard.css">
    <link rel = stylesheet href="../control/assest/js/dashboard.js">
    <style type="text/css">
        body,html{
            margin: 0;
            height: 100%;
        }


    </style>
    <title>Control</title>
</head>
<body>
<div id = "show" style="height: 100%;">
    <table class="table">
        <thead class="thead-dark">
        <tr class="text-center">
            <th scope="col">姓名</th>
            <th scope="col">身份</th>
            <th scope="col">年龄</th>
            <th scope="col">商品数</th>
            <th scope="col">操作</th>
        </tr>
        </thead>
        <tbody>
        <tr v-for="mum in list_m" :key = "mum" class="text-center">
            <th scope="row" class="text-center">
                {{mum.u_name}}
            </th>
            <td>{{mum.is_admin==true?'管理员':'用户'}}</td>
            <td>{{mum.u_age}}</td>
            <td>{{mum.u_num}}</td>
            <td v-if="mum.is_admin"><button  class="disabled btn btn-block mx-auto" style="width:30%;height: 100%;">删除</button></td>
            <td v-else><button  class="btn btn-danger mr-2" style="width:30%;height: 100%;" @click="delete_m(mum.u_id)">删除</button></td>
        </tr>
        </tbody>
    </table>


</div>


<script src="../../js/jquery-3.6.0.slim.min.js" ></script>
<script src="../../js/bootstrap.bundle.min.js" ></script>
<script src="../../js/vue.global.js"></script>
<script src="../../js/axios.min.js"></script>
<script src="../../layer/layer.js"></script>
<script src="../../js/my-axios.js"></script>

<script>

    const show = {
        data(){
            return{
                ifSimply:false,
                num_item:1,
                list_m:[
                ]
            }

        },
        methods:{
            delete_m(m){
                let item = '';

                for(let i = 0; i<this.list_m.length; i++){
                    if(this.list_m[i].u_id == m){
                        item = this.list_m[i];
                        break;
                    }
                }
                myAxios.post('/con/deleteUser',item).then((res)=>{
                    console.log(res.data.data);
                })
            },
            get_Alluser(){
                myAxios.get('/con/getAbuser').then((res)=>{
                   this.list_m =  res.data.data;
                })
            }
        },
        mounted(){
            this.get_Alluser();
        }
    };
    Vue.createApp(show).mount('#show')


</script>

</body>
</html>